package com.example.demo.dto;

import java.io.Serializable;

public class R<T> implements Serializable {

    private Integer status;
    private Integer code;
    private String msg;
    private Object data;

    public static <T> R<T> ok(T t, String msg) {
        R r = new R();
        r.setStatus(0);
        r.setCode(0);
        r.setData(t);
        r.setMsg(msg);
        return r;
    }

    public static <T> R<T> ok(T t) {
        return ok(t, "");
    }

    public static <T> R<T> no(T t, String msg) {
        R r = new R();
        r.setStatus(500);
        r.setCode(500);
        r.setData(t);
        r.setMsg(msg);
        return r;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public static <T> R<T> no(T t) {
        return no(t, "");
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
